<% add_decidim_page_title(t("title", scope: "decidim.meetings.admin.registrations.form")) %>
<div class="item_show__header">
  <h1 class="item_show__header-title">
    <%= t("title", scope: "decidim.meetings.admin.registrations.form") %>
    <div class="flex items-center gap-x-4 ml-auto">
      <%= link_to t("registrations", scope: "decidim.meetings.admin.registrations.form"), meeting_registrations_attendees_path(meeting), class: "button button__sm button__transparent-secondary #{"disabled" unless allowed_to? :read_invites, :meeting, meeting: meeting}" %>
      <%= link_to t("invites", scope: "decidim.meetings.admin.registrations.form"), meeting_registrations_invites_path(meeting), class: "button button__sm button__transparent-secondary #{"disabled" unless allowed_to? :read_invites, :meeting, meeting: meeting}" %>

      <% if allowed_to? :export_registrations, :meeting, meeting: meeting %>
        <div class="relative">
          <button class="button button__sm button__transparent-secondary" data-controller="dropdown" data-target="export-dropdown">
            <%= t "actions.export", scope: "decidim.admin" %>
            <%= icon "arrow-down-s-line" %>
            <%= icon "arrow-down-s-line" %>
          </button>

          <ul class="dropdown dropdown_bottom" id="export-dropdown">
            <% %w(CSV JSON Excel).each do |format| %>
              <li class="dropdown__item">
                <%= link_to export_meeting_registrations_path(meeting_id: meeting, format:), class: "dropdown__button" do %>
                  <%= t("decidim.admin.exports.export_as", name: t("decidim.#{current_component.manifest.name}.admin.exports.registrations"), export_format: format) %>
                <% end %>
              </li>
            <% end %>
          </ul>
        </div>
      <% end %>

      <%= link_to t("registration_form" , scope: "decidim.meetings.admin.registrations.form"), edit_meeting_registrations_form_path(meeting_id: meeting.id), class: "button button__sm button__transparent-secondary" %>
      <%= link_to t("manage_questions" , scope: "decidim.meetings.admin.registrations.form"), edit_questions_meeting_registrations_form_path(meeting_id: meeting.id), class: "button button__sm button__transparent-secondary" %>
    </div>
  </h1>
</div>

<div class="item__edit item__edit-1col">
  <div class="item__edit-form">
    <%= cell("decidim/announcement", t("recommendation_message", scope: "decidim.meetings.admin.registrations.form"), callout_class: "warning" ) %>

    <%= decidim_form_for(@form, url: meeting_registrations_path, html: { class: "form-defaults form edit_meeting_registrations mt-4" })  do |f| %>
      <%= render partial: "form", object: f %>

      <div class="item__edit-sticky">
        <div class="item__edit-sticky-container">
          <%= f.submit t(".save"), class: "button button__sm button__secondary" %>
        </div>
      </div>
    <% end %>
  </div>
</div>
